#!/usr/bin/python2.4
#
# Copyright 2011 Google Inc. All Rights Reserved.

from gaesessions import get_current_session

class LoginUtil:
    
    @staticmethod
    def SetUserLogin(email):
        session = get_current_session()
        session['email'] = email
        return session
    
    @staticmethod
    def Logout():
        session = get_current_session()
        if session.is_active():
            session.terminate()
    
    @staticmethod
    def IsUserLogin():
        session = get_current_session()
        if session.has_key('email'):
            email = session['email']
            if email:
                return True
            else:
                return False
        return False
    
    @staticmethod
    def GetLoginedUserEmail():
        session = get_current_session()
        if session.has_key('email'):
            email = session['email']
            if email:
                return email
            else:
                return None
        return None